/*
 * Copyright 2013 Alibaba.com All right reserved. This software is the
 * confidential and proprietary information of Alibaba.com ("Confidential
 * Information"). You shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license agreement you entered
 * into with Alibaba.com.
 */
package com.yunos.tv.server.controller.web;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yunos.tv.biz.service.IUserService;
import com.yunos.tv.dal.domain.UserDomain;

/**
 * 类UserController.java的实现描述：TODO 类实现描述
 * @author riqi 2013-7-1 下午5:11:38
 */

@Controller
@RequestMapping(value = "/user")
public class UserController extends BaseController {

    @Autowired
    private IUserService userService;

    @ResponseBody
    @RequestMapping(value = "add", method = RequestMethod.GET, params = { "username", "password" })
    public String addUser(HttpServletRequest request, HttpServletResponse response) {
        UserDomain userDomain = new UserDomain();
        userDomain.setUsername(request.getParameter("username"));
        userDomain.setPassword(request.getParameter("password"));

        String lastUid = String.valueOf(userService.addUser(userDomain));

        return lastUid;
    }

    @ResponseBody
    @RequestMapping(value = "/count", method = RequestMethod.GET, params = { "!uid", "!username" })
    public String getCount() {
        return String.valueOf(userService.getCount());
    }
}
